package org.swirrel.util;

import java.lang.reflect.Method;
import java.awt.Component;

/**
 * <p>Title: Swirrel</p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2009</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 0.1
 */
public class MethodCall {

  private final boolean threaded;
  private final Method method;
  private final Component component;

  public MethodCall(boolean threaded, Method method, Component component) {
    this.threaded = threaded;
    this.method = method;
    this.component = component;
  }

  @Override public boolean equals(Object o) {
     if(o == this) {
       return true;
     } else if (o instanceof MethodCall) {
       MethodCall that = (MethodCall) o;
       return this.threaded == that.threaded && this.method.equals(that.method)
           && this.component.equals(that.component);
     }
     return false;
   }

   @Override public int hashCode() {
     return method.hashCode() + 37*component.hashCode() + (threaded ? 4711 : 1147);
    }

    public Method getMethod() {
      return method;
    }

    public Component getComponent() {
      return component;
    }

    public boolean isThreaded() {
      return threaded;
    }
}
